package com.gimi.cloud.jimi.dao.dao.moreInfo;

import com.gimi.cloud.jimi.dao.myMapper.MyMapper;
import com.gimi.cloud.jimi.dto.app.moreInfo.MoreInfoDTO;
import com.gimi.cloud.jimi.entity.app.moreInfo.MoreInfoEntity;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @auther loongs
 * @date 2018/1/9  10:31
 */
@Mapper
public interface MoreInfoDao extends MyMapper<MoreInfoEntity> {

    @Select("SELECT f_id,report_effection_end FROM rd_more_info WHERE user_id = #{userId} AND data_type = '7' ORDER BY f_id DESC LIMIT 1;")
    MoreInfoDTO getEffectionByUserId(@Param(value = "userId") Integer userId);

    @Select("SELECT * FROM rd_more_info WHERE user_id = #{userId} AND data_type = #{dataType} ORDER BY f_id DESC LIMIT 1;")
    MoreInfoEntity getMoreInfoByUserIdAndType(@Param(value = "userId")Integer userId, @Param(value = "dataType")int dataType);

    @Select("SELECT * FROM rd_more_info WHERE user_id = #{userId} AND data_type = #{dataType} AND getdata=#{getdata}  ORDER BY f_id DESC LIMIT 1;")
    MoreInfoEntity getMoreInfoByUserIdAndTypeAndData(@Param(value = "userId")Integer userId, @Param(value = "dataType")int dataType,@Param(value = "getdata")int getdata);

    @Select("SELECT * FROM rd_more_info WHERE user_id = #{userId}")
    List<MoreInfoDTO> selectByUser(Integer userId);
    
	@Select("SELECT * FROM rd_more_info WHERE report_effection_end > NOW() AND user_id = #{userId}")
	List<MoreInfoDTO> isEffection(@Param(value = "userId") Integer userId);

}
